﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using Galaktika.BI.Silverlight;

namespace Galaktika.BI.Runtime.Services
{
    [XmlRoot(Namespace=Common.Namespace)]
    [DataContract(Namespace = Common.Namespace)]
    public class InvokeResultSchema
    {
        public static readonly InvokeResultSchema Empty = new InvokeResultSchema(Galaktika.BI.Silverlight.Commands.CommandId.MockCommandId);

        public InvokeResultSchema()
        {
        }

        public InvokeResultSchema(string commandId)
        {
            if (string.IsNullOrEmpty(commandId))
            {
                throw new ArgumentNullException("commandId");
            }

            this.CommandId = commandId;
        }

        public InvokeResultSchema(string commandId, string content)
        {
            if (string.IsNullOrEmpty(commandId))
            {
                throw new ArgumentNullException("commandId");
            }
            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentNullException("content");
            }

            this.CommandId = commandId;
            this.Content = content;
        }

        public InvokeResultSchema(string commandId, string content, string contentType)
        {
            if (string.IsNullOrEmpty(commandId))
            {
                throw new ArgumentNullException("commandId");
            }
            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentNullException("content");
            }
            if (string.IsNullOrEmpty(contentType))
            {
                throw new ArgumentNullException("contentType");
            }

            this.CommandId = commandId;
            this.Content = content;
            this.ContentType = contentType;
        }

        [XmlElement]
        [DataMember]
        public string CommandId { get; set; }

        [XmlElement(IsNullable=true)]
        [DataMember]
        public string Content { get; set; }

        [XmlElement]
        [DataMember]
        public string ContentType { get; set; }
    }

    public class KnownContentTypes
    {
        public static readonly string RelationalData = "RelationalData";
        public static readonly string MultidimData = "MultidimData";
        public static readonly string Variables = "Variables";
        public static readonly string Empty = "Empty";
        public static readonly string Error = "Error";
        public static readonly string String = "String";
    }
}
